<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="js/jquery-3.3.1.min.js"></script>
</head>
<body>
     邮箱:<input type="text" id="mail"> <button onclick="sendMail()">发送</button> <br>
     验理码:<input type="text" id="code"> <br>
     <button onclick="zhuce()">注册</button>
</body>
</html>

<script>
    function sendMail() {
         $.ajax({
            url:'/sendMail',
            data:{mail:$("#mail").val()},
            success:function (res) {
                alert('发送成功');
            } ,
            error:function () {
                alert('网络错误');
            }

         });
    }

    function  zhuce() {
        $.ajax(
            {
                url: '/checkCode',
                data: {mail: $("#mail").val(), code: $("#code").val()},
                success: function(res) {

                    if (res==true)
                    {
                        alert("注册成功");
                    }
                    else
                    {
                        alert("注册失败");
                    }
                },
                error:function () {
                    alert('网络错误');
                }
            }
        )
    }

</script>